import { defHttp } from '@/utils/http/axios';

enum Api {
  getdeviceAPI = '/mc/device/page',
  bindAuthorizationCodeApi = '/mc/device/bindAuthorizationCode',
  updateRemarkAPI = '/mc/device/updateOwner',
  getUserMapAPI = '/sys/user/map',
  getUserlsitAPI = '/fb/account/list',
  unbindAuthorizationCodeApi = '/mc/device/unbindAuthorizationCode',
  getErrorApi = '/mc/task/getError',
  reportAbnormalAPI = '/mc/task/uploadError',
  fbDeviceApi = '/fb/device/page',
  updatefbDeviceApi = '/fb/device/update_device_with_scripts',
  updatefbDevicenodepageApi = '/fb/deviceNode/node_page',
  fbDeviceDelApi = '/fb/device/delete_device',
  getDeviceEmailApi = '/fb/device/email/get',
  addDeviceEmailApi = '/fb/device/email/add',
}

export function getFbDeviceAPI(params) {
  return defHttp
    .post(
      {
        url: Api.fbDeviceApi,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
      console.log(err, '获取设备');
    });
}
export function getavatarAPI(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/avatar/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
      console.log(err, '获取设备');
    });
}

export function getavatarstatusAPI(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/avatar/update/marking/status',
        data: params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '获取设备');
    });
}
export function delFbDeviceAPI(params) {
  return defHttp
    .post(
      {
        url: Api.fbDeviceDelApi,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '获取设备');
    });
}

//授权码
export function getdeviceAPI(params) {
  params['current'] = params.page;
  params['size'] = params.pageSize;
  return defHttp
    .post(
      {
        url: Api.getdeviceAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
      console.log(err, '获取设备');
    });
}

export function bindAuthorizationCode(params) {
  return defHttp
    .post(
      {
        url: Api.bindAuthorizationCodeApi,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '绑定设备');
    });
}
export function postimagesZip(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/images-zip',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '绑定设备');
    });
}

export function updateRemarkAPI(params) {
  return defHttp
    .post(
      {
        url: Api.updateRemarkAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    })
    .catch((err) => {
      console.log(err, '设置备注');
    });
}

//用户管理
export function getUserMapAPI() {
  return defHttp
    .post(
      {
        url: Api.getUserMapAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function getUserlsitAPI() {
  return defHttp
    .get(
      {
        url: Api.getUserlsitAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

//用户管理
export function updatefbDeviceApi(params) {
  return defHttp
    .post(
      {
        url: Api.updatefbDeviceApi,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function updatecmdDeviceApi(params) {
  return defHttp
    .post(
      {
        url: '/fb/device/update/cmd',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deviceNodeupdate(params) {
  return defHttp
    .post(
      {
        url: '/fb/deviceNode/update',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
//用户管理
export function updatefbDevicenodepageApi(params) {
  return defHttp
    .post(
      {
        url: Api.updatefbDevicenodepageApi,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function senddeviceNodecmd(params) {
  return defHttp
    .post(
      {
        url: '/fb/deviceNode/send/cmd',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function updatescript(params) {
  return defHttp
    .post(
      {
        url: '/fb/device/update/script',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
//用户管理
//用户管理
export function senddevicemand(params) {
  return defHttp
    .post(
      {
        url: '/fb/device/send/cmd',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function unbindAuthorizationCodeApi(params) {
  return defHttp
    .get(
      {
        url: `${Api.unbindAuthorizationCodeApi}?device=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function getstatistics() {
  return defHttp
    .get(
      {
        url: `/fb/device/statistics`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deviceNodedetailinfo(params) {
  return defHttp
    .get(
      {
        url: `/fb/deviceNode/detail_info?nodeId=${params.id}&type=${params.type}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function photosDelete(id) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/photos/delete?id=${id}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postDelete(id) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/post/delete?id=${id}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
//获取异常
export function getErrorApi(params) {
  return defHttp
    .get(
      {
        url: `${Api.getErrorApi}?device=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

//上报异常
export function reportAbnormalAPI(params) {
  return defHttp
    .get(
      {
        url: `${Api.reportAbnormalAPI}?device=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
//获取采集详情
export function gettaskuserinfo(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/info?taksId=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function posttasksave(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/save',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function posttaskpage(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postlistpage(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/list/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function posttaskupdate(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/update',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function posttaskuserlogpage(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/log/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deleteTaskcount(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/log/unread/count?uid=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function taskstatistics(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/statistics`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function readstatus(params) {
  return defHttp
    .post(
      {
        url: `/sys/task/user/log/update/read/status`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deleteTask(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/delete?id=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function commentinfoId(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/report/comment/list?infoId=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deletelistTask(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/list/delete?id=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postUserListPage(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postUserListPagelist(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/page/id/list',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function posthistoryListPage(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/add/history/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function posthistoryListsave(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/add/history/save',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postUserList(params) {
  return defHttp
    .post(
      {
        url: '/sys/user/page/user',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function postReviewReport(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/review/report',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postdistributeUserList(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/distribute/facebook/to/user',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postUserLisupdate(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/user/update',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function getPersonalInfo(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/info`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function getStatistics(params) {
  console.log(params);

  return defHttp
    .get(
      {
        url: `/sys/task/user/statistics`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function hasfacebook(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/sys/user/account/has/facebook`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postUpdateStatus(params) {
  return defHttp
    .post(
      {
        url: `/sys/task/user/update/stage/status`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deletePersonalTask(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/delete?taskId=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postverifyListPage(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/verify/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deleteverify(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/verify/delete?id=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postCmdSave(params) {
  return defHttp
    .post(
      {
        url: `/fb/cmd/save`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deleteCmd(params) {
  return defHttp
    .get(
      {
        url: `/fb/cmd/delete?id=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function useravatorlist(params) {
  return defHttp
    .get(
      {
        url: `/sys/task/user/get/avator/list?uid=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postCmdUpdate(params) {
  return defHttp
    .post(
      {
        url: `/fb/cmd/update`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postCmdPage(params) {
  return defHttp
    .post(
      {
        url: `/fb/cmd/page`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function deleteAcciybt(params) {
  return defHttp
    .get(
      {
        url: `/fb/account/delete?id=${params}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function exceptionStatistics() {
  return defHttp
    .get(
      {
        url: `/sys/task/exception/statistics`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postAcciybtSave(params) {
  return defHttp
    .post(
      {
        url: '/fb/account/save',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postaccountlog(params) {
  return defHttp
    .post(
      {
        url: '/fb/account/log/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function postTaskExceptionPage(params) {
  return defHttp
    .post(
      {
        url: '/sys/task/exception/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function postAcciybtListPage(params) {
  return defHttp
    .post(
      {
        url: '/fb/account/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postfacebookUpdate(params) {
  return defHttp
    .post(
      {
        url: '/sys/user/facebook/update',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postfacebookPage(params) {
  return defHttp
    .post(
      {
        url: '/sys/user/facebook/page',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function postAcciybtUpdate(params) {
  return defHttp
    .post(
      {
        url: '/fb/account/update',
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

// 获取设备邮箱列表
export function getDeviceEmailAPI() {
  return defHttp
    .get(
      {
        url: Api.getDeviceEmailApi,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

// 添加设备邮箱
export function addDeviceEmailAPI(params) {
  return defHttp
    .post(
      {
        url: Api.addDeviceEmailApi,
        data: params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
